all: serializeStem.dat serializeNoStem.dat normalizeQuery.so createIndex.so rapidUtils.so titlesPR 

pagerank.txt: dict pagerank.py iteruj.so
	python pagerank.py

dict: dump.py
	python dump.py
	
titlesPR: titles.txt pagerank.txt
	python includePageRank.py

iteruj.so: iteruj.o
	gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions iteruj.o -L/usr/local/lib -o iteruj.so

iteruj.o: iteruj.c
	gcc -pthread -fno-strict-aliasing -g -fwrapv -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c iteruj.c -o iteruj.o

serializeStem.dat: indeksStaticStemFull.dat createIndex
	./createIndex indeksStaticStemFull.dat serializeStem.dat

serializeNoStem.dat: indeksStaticNoStemFull.dat createIndex
	./createIndex indeksStaticNoStemFull.dat serializeNoStem.dat
    
rapidUtils.so: rapidUtils.o
	gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions rapidUtils.o -L/usr/local/lib -o rapidUtils.so

rapidUtils.o: rapidUtils.c
	gcc -pthread -fno-strict-aliasing -g -fwrapv -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c rapidUtils.c -o rapidUtils.o

indeks.so: p_indeks.o
	gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions p_indeks.o -L/usr/local/lib -o indeks.so

p_indeks.o: p_indeks.c indeks.c 
	gcc -pthread -fno-strict-aliasing -g -fwrapv -O2 -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c p_indeks.c -o p_indeks.o

p_createIndex.o: p_createIndex.c createIndex.c indeks.c indeksSerialize.c
	gcc -pthread -fno-strict-aliasing -g -fwrapv -O2 -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c p_createIndex.c -o p_createIndex.o

createIndex.so: p_createIndex.o staticNode.c indeks.c
	gcc -pthread -lm -shared -Wl,-O1 -Wl,-Bsymbolic-functions p_createIndex.o -L/usr/local/lib -o createIndex.so

node.so: p_node.o
	gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions p_node.o -L/usr/local/lib -o node.so

p_node.o: p_node.c node.c
	gcc -pthread -fno-strict-aliasing -g -fwrapv -O2 -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c p_node.c -o p_node.o

normalizeQuery.so: normalizeQuery.o
	gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions normalizeQuery.o -L/usr/local/lib -o normalizeQuery.so
	
normalizeQuery.o: normalizeQuery.c
	gcc -pthread -fno-strict-aliasing -g -fwrapv -O2 -Wall -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.5 -c normalizeQuery.c -o normalizeQuery.o
	
convert: convert.c
	gcc -O2 $< -o $@
		
%.pyx: %.py
	cp $< $@
		
titles.txt: titles.py wiki.txt
	python titles.py

c_morfo.so: c_stemorfo.so
		
c_stemming.so: c_stemorfo.so
		
c_stemorfo.so: stemming.pyx stemorfo.pyx indeks.so node.so morfo.pyx
	python setup.py build_ext --inplace

wiki2.txt: convert
	./convert

wiki3.txt: wiki2.txt c_stemorfo.so morfo3.txt c_stemming.so
	python run_stemorfo.py

wiki3a.txt: wiki2.txt c_morfo.so morfo3.txt
	python run_morfo.py

createIndex: createIndex.c indeks.c indeksSerialize.c
	gcc -lm -o createIndex createIndex.c
    
indeksStaticStemFull.dat: wiki3.txt createIndex createIndex.so
	./createIndex wiki3.txt indeksStaticStem.dat nodeStaticStem.dat indeksStaticStemFull.dat

indeksStaticNoStemFull.dat: wiki3a.txt createIndex createIndex.so
	./createIndex wiki3a.txt indeksStaticNoStem.dat nodeStaticNoStem.dat indeksStaticNoStemFull.dat

morfo2.txt: convert
	./convert

morfo3.txt: morfo2.txt cut.py
	python cut.py

clean:
	rm -f *.o *.pyx *.so convert createIndex wiki2.txt wiki3.txt morfo2.txt morfo3.txt
	
